const mongoose = require("mongoose");
const Schema = mongoose.Schema;

const UserQuesSchema = mongoose.Schema({
  // 调查户类型
  target: {
    type: Number,
    default: -1,
  },
  // 问卷编号
  title: {
    type: String,
    default: "",
  },
  // 组别
  group: {
    type: String,
  },
  // 问卷题目组序列
  body: {
    type: Array,
  },
  // 问卷状态 0：未上传，1：待审核，2：已通过，3：已驳回
  state: {
    type: Number,
    require: true,
    enum: [0, 1, 2, 3],
  },
  // 发布时间
  time: {
    type: Date,
    require: true,
  },
  // 发布者
  user: {
    type: Schema.Types.ObjectId,
    ref: "User",
    require: true,
  },
  // 问题清单
  userproblem: {
    type: Schema.Types.ObjectId,
    ref: "UserProblem",
  },
  // 意见
  opinions: {
    type: Schema.Types.ObjectId,
    ref: "Opinion",
  },
  // 入户资料
  filedata: {
    type: Schema.Types.ObjectId,
    ref: "FileData",
  },
});

const UserQues = mongoose.model("UserQues", UserQuesSchema);
module.exports = UserQues;
